/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DATA.SubstanceDB;

import input.ExcelTools;

import java.io.File;
import java.util.Vector;

/**
 *
 * @author Bunkowski
 */
public class SubstanceDB {

    public static Vector<SubstanceDBItem> substances = new Vector<SubstanceDBItem>();

    public static void addFile(File f) {
        Vector<String[]> fileContent = ExcelTools.importXLS(f, 0);
        String filenameForErrorReport = "Unknown entry";
        for (int i = 1; i < fileContent.size(); i++) {
            try{
            String[] line = fileContent.elementAt(i);
            filenameForErrorReport = line[0];
            String name = line[0];
            String synonyme = line[1];
            if(line[2].trim().isEmpty()) line[5] = "-1";
            double RtGc = Double.parseDouble(line[2]);
            double RtMcc = Double.parseDouble(line[3]);
            double k0Monomer = Double.parseDouble(line[4]);
            if(line[5].trim().isEmpty()) line[5] = "-1";
            double k0Dimer = Double.parseDouble(line[5]);
            SubstanceDBItem sdi = new SubstanceDBItem(name, synonyme, RtGc, RtMcc, k0Monomer, k0Dimer);
            substances.add(sdi);
            }catch(Exception ex){
                System.out.println("Bad database entry found, skipping :"+filenameForErrorReport);
            }        
        }


    }
}
